<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>编辑昼夜权重</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="${pageContext.request.contextPath}/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/css/animate.min.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/css/style.min.css?v=4.1.0" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/jQuery-Validation/css/validationEngine.jquery.css" rel="stylesheet">
    <style type="text/css">
        .formErrorContent{color: red;}
    </style>
</head>
<body class="gray-bg">
<div class="formErrorContent"></div>
    <div class="container" style="margin-top: 20px">
        <form class="form-horizontal" role="form" id="editBillTimingForm" autocomplete="off">
                <input type="hidden" name=timingType id="timingType">
                <div class="form-group">
                    <label class="col-sm-4 control-label">夜晚计费单价(元):</label>
                    <div class="col-sm-4">
                        <input type="text" class="form-control validate[required,min[0],custom[floatingNumber2]]" name="timingNightRate" id="timingNightRate" placeholder="夜晚计费单价">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-4 control-label">白天计费单价(元):</label>
                    <div class="col-sm-4">
                        <input type="text" class="form-control validate[required,min[0],custom[floatingNumber2]]" name="timingDayRate" id="timingDayRate" placeholder="白天计费单价">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-4 control-label">夜晚开始时间(点):</label>
                    <div class="col-sm-4">
                        <input type="text" class="form-control validate[required,min[0],max[23]]" name="timingNightStart" id="timingNightStart" placeholder="夜晚开始时间">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-4 control-label">白天开始时间(点):</label>
                    <div class="col-sm-4">
                        <input type="text" class="form-control validate[required,min[0],max[23]]" name="timingDayStart" id="timingDayStart" placeholder="白天开始时间">
                    </div>
                </div>
                <div class="form-group" style="margin-left: 150px;margin-top: 50px">
                    <div class="col-sm-6  control-label">
                        <button type="button" class="btn btn-default" onclick="closeForm();">关闭</button>
                        &nbsp;&nbsp;&nbsp;&nbsp;<button type="submit" class="btn btn-primary" id="save">保存</button>
                    </div>
                </div>
         </form>
    </div>
<script src="${pageContext.request.contextPath}/js/jquery.min.js?v=2.1.4"></script>
<script src="${pageContext.request.contextPath}/js/bootstrap.min.js?v=3.3.6"></script>
<script src="${pageContext.request.contextPath}/js/content.min.js?v=1.0.0"></script>
<script src="${pageContext.request.contextPath}/js/plugins/layer/layer.min.js"></script>
<script src="${pageContext.request.contextPath}/js/public/ttbj-core.js"></script>
<script src="${pageContext.request.contextPath}/jQuery-Validation/js/jquery.validationEngine.js"></script>
<script src="${pageContext.request.contextPath}/jQuery-Validation/js/jquery.validationEngine-zh_CN.js"></script>
<script type="text/javascript">
var timingType;
$(function () {
	timingType = $.getUrlParam("type");
    //是否验证成功
    $('#editBillTimingForm').validationEngine('attach', {
        validationEventTrigger : 'blur',
        promptPosition: 'inline',
        scroll: false,
        focusFirstField : true,
        onValidationComplete : function (form, valid) {
            if (valid){
            	modifyBillTimingInfo();
            }
        }
    });
    //回显数据
    echoBillTimingInfo();
});

//点击编辑回显数据
function echoBillTimingInfo(){
    $.ajax({
        url: "../bill/echoBillTimingInfo.htm",
        cache: false,
        type: "get",
        dataType: "json",
        beforeSend:function(){layer.load(0, {shade:false});},
        complete:function(){layer.closeAll("loading");},
	    data: {"timingType": timingType},
        success: function (result) {
            if (result.status == 0) {
                var data = result.data;
                $("#editBillTimingForm").formatForm(data);
                return;
            }
        }
    });
}

//关闭窗口
function closeForm() {
    var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
    parent.layer.close(index);
}

//修改货车信息
function modifyBillTimingInfo(){
    $.ajax({
        url: "../bill/modifyBillTimingInfo.htm",
        cache: false,
        type: "post",
        dataType: "json",
        data : $("#editBillTimingForm").serialize(),
        beforeSend:function(){layer.load(0, {shade:false});},
        complete:function(){layer.closeAll("loading");},
        success: function (result) {
            if (result.status == 0) {
                parent.layer.msg(result.message, {icon: 1});
                parent.$table.bootstrapTable('refresh', {url: '../bill/getBillTimingInfo.htm'});
            } else {
                parent.layer.msg(result.message, {icon: 2});
            }
            closeForm();
        }
    });
}
</script>
</body>
</html>